﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

namespace HodhodNews.Web
{
    public partial class Register : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void CreateUserWizard1_ContinueButtonClick(object sender, EventArgs e)
        {
           
            Response.Redirect("~");
        }

        protected void cuwPaid_CreatingUser(object sender, LoginCancelEventArgs e)
        {
            ValidatePaymentCode(sender, e);
        }
        private void ValidatePaymentCode(object sender, LoginCancelEventArgs e)
        {
            var parentControl = ((CreateUserWizard)sender).WizardSteps[0].Controls[0].Controls[0];
            var txtPaymentCode = parentControl.FindControl("txtPaymentCode") as TextBox;

            if (txtPaymentCode.Text.ToLower() == "vip0707")
            {
            }
            else
            {
                btnFree.Visible = false;
                btnPaid.Visible = false;
                cuwPaid.Style["display"] = "";
                e.Cancel = true;
            }
        }

        protected void cuwFree_CreatedUser(object sender, EventArgs e)
        {
            Response.Redirect("~");
        }

        protected void cuwPaid_CreatedUser(object sender, EventArgs e)
        {
            var username = ((CreateUserWizard)sender).UserName;
            var user = Membership.GetUser(username);
            user.Comment = "vip0707";
            Membership.UpdateUser(user);
            Response.Redirect("~");
        }
    }
}